<template>
  <div id="app">
    <router-view></router-view>

    <van-tabbar v-model="active">
      <van-tabbar-item icon="wap-home-o" to="/home">首页</van-tabbar-item>
      <van-tabbar-item icon="user-circle-o">会员</van-tabbar-item>
      <van-tabbar-item icon="shopping-cart-o" :badge="number" to="/car"
        >购物车</van-tabbar-item
      >
      <van-tabbar-item icon="search" to="/seach">搜索</van-tabbar-item>
    </van-tabbar>
  </div>
</template>
<script>
import { EventBus } from "@/utils/eventBus.js";
export default {
  data() {
    return {
      active: 0, //选中的标签
      number: 0, //购物车的数量
    };
  },
  mounted() {
    EventBus.$on("sendNum", (num) => {
      this.number = num;
    });
    EventBus.$on("addNum", (addNum) => {
      this.number += addNum;
    });
  },
};
</script>
<style lang="less">
</style>
